package Zadanie7;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;


public class Client {

	/**
	 * @param args
	 */
	
	private static Socket s;
	private static String hostname = "127.0.0.1";
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		InputStream is = null;
		OutputStream os = null;
		

			try {
				s = new Socket(hostname, Server.getPort());
				is = s.getInputStream();  
				os = s.getOutputStream();
	        } catch (UnknownHostException e) {
	            System.err.println("Don't know about host: hostname");
	        } catch (IOException e) {
	            System.err.println("Couldn't get I/O for the connection to: hostname");
	        }
				
	    
	         if (s != null && os != null && is != null) {
	                 try {
	    
	                	 
	                	ObjectInputStream ois = new ObjectInputStream(is);  
	                	ObjectOutputStream oos = new ObjectOutputStream(os);
	                	
	                	while(true) {
	                		VectorM vector = (VectorM) ois.readObject();	
	                		vector.multiply();
	                		oos.writeObject(vector); 
	                		vector = null;
	                		//Thread.sleep(1);
	                	}
	    
	                	 
	                 } catch (UnknownHostException e) {
	                     System.err.println("Trying to connect to unknown host: " + e);
	                 } catch (IOException e) {
	                     System.err.println("IOException:  " + e);
	                 } catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} /*catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}*/
	             }
	         } 	
			
				
			
		
	

}
